﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Resources;
using Mundo_3D;
using System.Threading;


namespace Simulador_Quadrotor
{
    public partial class PrincipalForm : Form
    {
        private static Game1 game;


        public PrincipalForm()
        {
            InitializeComponent();
            this.label1.Text = "Versión : " + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();

        }

        private void toolStripButtonPID_Click(object sender, EventArgs e)
        {
            //mostramos el formulario del pid
            Form formularioPID = new ControlPIDForm();
            formularioPID.Show(this);
        }

        private void toolStripButtonSimulador2D_Click(object sender, EventArgs e)
        {
            //mostramos el formulario del pid
            Form formularioSimulador2D = new Simulador2DForm();
            formularioSimulador2D.Show(this);

        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {

            Thread thread = new Thread(Crea3D);
            thread.IsBackground = false;
            thread.Start();

        }

        private static void Crea3D()
        {
            Form_3D form = new Form_3D();
            form.Disposed += new EventHandler(form_Disposed);
            using (game = new Game1(form))
            {
                form.Show();
                form.TopMost = true;
                game.Run();
            }
        }
        static void form_Disposed(object sender, EventArgs e)
        {
            game.Exit();
            Thread.CurrentThread.Abort();
        }
    }
}
